﻿using System;
using System.Collections.Generic;
using System.Text;
using Domain.Commons;
using ORM.Annotations;

namespace Motorbike.Model
{
    [EntityTable("sys_user", IsCache = true, Title = "系统用户")]
    public class User : DomainObject
    {
        [EntityFeild("password", Title = "登录密码")]
        public string Password { get; set; }

        [EntityFeild("role_id")]
        public Role RoleId { get; set; }

        [EntityFeild("create_date", Title = "创建日期")]
        public DateTime CreateDate { get; set; }

        public static User Create()
        {
            User instance = new User();
            instance.CreateDate = DateTime.Now;
            instance.RoleId = Role.AppOperator;
            return instance;
        }
    }

    [EntityTable("sys_login_log", Title = "用户登录日志")]
    public class LoginLog : Identifer
    {
        [EntityFeild("id", Id = true)]
        public string Id { get; set; }

        [EntityFeild("user_id")]
        public string UserId { get; set; }

        [EntityFeild("login_time")]
        public DateTime LoginTime { get; set; }

        [EntityFeild("host_name")]
        public string HostName { get; set; }

        [EntityFeild("host_address")]
        public string HostAddress { get; set; }

        [EntityFeild("logout_time")]
        public DateTime LogoutTime { get; set; }
    }

    public enum Role
    {
        /// <summary>
        /// 系统超级管理员
        /// </summary>
        SysAdmin = 0,

        /// <summary>
        /// 应用程序管理员
        /// </summary>
        AppAdmin = 1,

        /// <summary>
        /// 基本操作员
        /// </summary>
        AppOperator = 100
    }
}
